#pragma once
#include <memory>
#include "AudioScenesInItem.h"
#include "AudioScenesOutItem.h"
#include "encoder/AEncoder.h"
namespace Media{

    class AudioMixer{
    public:
        using Ptr = std::shared_ptr<AudioMixer>;

        AudioMixer();
        ~AudioMixer();
        bool Start();
        bool Stop();

        bool AddItem(uint32_t itemId, const AudioScenesInItemConfig& config);
        bool SetItem(uint32_t itemId, const AudioScenesInItemConfig& config);
        bool DelItem(uint32_t itemId);
        bool GetItems(std::map<uint32_t, AudioScenesInItemConfig>& items);
        bool GetOneInItem(uint32_t, AudioScenesInItemConfig& config);

        bool SetOutConfig(const AudioScenesOutItemConfig& config);
        bool GetOutConfig(AudioScenesOutItemConfig& config);
        bool AddOutSource(OutputSource::OutputSourceId id,const std::string& name); 
        bool RemoveOutSource(OutputSource::OutputSourceId id);

        bool SetDefaultOutCb(std::function<void (const FrameCommon::Frame::Ptr&)> cb);
    private:
        std::recursive_mutex m_mux;
        std::map<uint32_t, AudioScenesInItem::Ptr> m_inItems;
        
        AudioScenesInItemConfig m_outConfig;
        std::map<uint32_t, std::string> m_outSources;  

        AEncoder::Ptr m_encoder;
    };

}